package com.visikard.ui.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;

import com.visikard.item.MerchantPeopleNearByItem;
import com.visikard.ui.R;
import com.visikard.utility.BitmapUtils;
import com.visikard.utility.UILImageUtils;

public class MerchantPeopleNearByAdapter extends ArrayAdapter<MerchantPeopleNearByItem> {

	public MerchantPeopleNearByAdapter(Context context, List<MerchantPeopleNearByItem> peopleList) {
		super(context, R.layout.merchant_people_near_thumb, peopleList);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;
		Holder holder = null;

		if (row == null) {
			LayoutInflater inflater = LayoutInflater.from(getContext());
			row = inflater.inflate(R.layout.merchant_people_near_thumb, parent, false);

			holder = new Holder();
			holder.kardThumb = (ImageView) row.findViewById(R.id.kard_thumb);

			row.setTag(holder);
		}
		else {
			holder = (Holder) row.getTag();
		}

		MerchantPeopleNearByItem item = getItem(position);

		if (item != null) {
			UILImageUtils.loadImage(holder.kardThumb, item.getImageUrl(), 1, BitmapUtils.ROUND_NONE, 0, 0, 0, 0,
					R.drawable.icon_kard);
		}

		return row;
	}

	private class Holder {
		ImageView kardThumb;
	}
}